package stu.day25_day32.day29;

import java.util.ArrayList;
import java.util.List;

public class hw2 {

    List<List<Integer>> list = new ArrayList<>();
    List<Integer> arr = new ArrayList<>();
    public List<List<Integer>> combine(int n, int k) {
        backtrack(n,k,0);
        return list;

    }

    public void backtrack(int n, int k,int index){
        if(arr.size()==k){
            list.add(new ArrayList<>(arr));
        }

        for(int i=index;i<n;i++){
            arr.add(i+1);
            backtrack(n,k,i+1);
            arr.removeLast();
        }


    }


}
